<template>
  <div class="homeIndex-container">
    <div class="homeIndex-row">
      <div class="homeIndex-col">
        <div class="homeIndex-colTitle">
          <h3>通知公告</h3>
          <span @click="jumpRouter('1')">更多...</span>
        </div>
        <ul>
          <li @click="$router.push('/menuDetail/'+item.Id)" :key="i" v-for="(item,i) in newsData.inform">{{item.Title}}</li>
        </ul>
      </div>
      <div class="homeIndex-col">
        <div class="homeIndex-colTitle">
          <h3>情况通报</h3>
          <span @click="jumpRouter('3')">更多...</span>
        </div>
        <ul>
          <li @click="$router.push('/menuDetail/'+item.Id)" :key="i" v-for="(item,i) in newsData.condition">{{item.Title}}</li>
        </ul>
      </div>
      <div class="homeIndex-col">
        <div class="homeIndex-colTitle">
          <h3>节能动态</h3>
          <span @click="jumpRouter('2')">更多...</span>
        </div>
        <ul>
          <li @click="$router.push('/menuDetail/'+item.Id)" :key="i" v-for="(item,i) in newsData.saveStatus">{{item.Title}}</li>
        </ul>
      </div>
    </div>
    <div class="homeIndex-row">
      <div class="homeIndex-col2">
        <div class="homeIndex-colTitles">
          <h3>政策法规</h3>
          <span @click="jumpRouter('4')">更多...</span>
        </div>
        <ul>
          <li @click="$router.push('/menuDetail/'+item.Id)" :key="i" v-for="(item,i) in newsData.policy">{{item.Title}}</li>
        </ul>
      </div>
      <div class="homeIndex-col2">
        <div class="homeIndex-colTitles">
          <h3>节能知识</h3>
          <span @click="jumpRouter('5')">更多...</span>
        </div>
        <ul>
          <li @click="$router.push('/menuDetail/'+item.Id)" :key="i" v-for="(item,i) in newsData.saveKnowledge">{{item.Title}}</li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      newsData: {
        inform: [],
        saveStatus: [],
        condition: [],
        policy: [],
        saveKnowledge: []
      }
    }
  },
  methods: {
    jumpRouter(num) {
      this.$router.push(`/menuList/${num}`)
    },
    // 获取信息列表
    async getNewsList(newsTitle, newsType) {
      const result = await this.$get('/api/News', { category: newsTitle, pageSize: 9, pageIndex: 1 })
      console.log(result)
      this.newsData[newsType] = result.Data;
    }
  },
  created() {
    this.getNewsList('通知公告', 'inform');
    this.getNewsList('情况通报', 'condition');
    this.getNewsList('节能动态', 'saveStatus');
    this.getNewsList('政策法规', 'policy');
    this.getNewsList('节能知识', 'saveKnowledge');
  }
}
</script>

<style lang="scss" scoped>
.homeIndex-container {
  display: flex;
  width: 100%;
  flex-direction: column;
  .homeIndex-row {
    display: flex;
    flex-direction: row;
    margin-bottom: 15px;
    .homeIndex-col {
      width: 320px;
      height: 345px;
      border: 1px solid #bbdbf7;
      &:nth-child(2) {
        margin: 0 10px;
      }
      ul {
        padding: 10px 20px 0 15px;
        li {
          height: 32px;
          border-bottom: 1px dashed #bbdbf7;
          line-height: 32px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          padding-left: 10px;
          background: url("../../static/lzbg10.gif") no-repeat left;
          background-size: 3px 5px;
          &:hover {
            color: blue;
            cursor: pointer;
            text-decoration: underline;
          }
        }
      }
    }
  }
}

.homeIndex-col2 {
  flex: 1;
  border: 1px solid #bbdbf7;
  height: 345px;
  margin-right: 10px;
  &:nth-child(2) {
    margin-right: 0;
  }
  ul {
    padding: 10px 20px 0 15px;
    li {
      height: 32px;
      border-bottom: 1px dashed #bbdbf7;
      line-height: 32px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding-left: 10px;
      background: url("../../static/lzbg10.gif") no-repeat left;
      background-size: 3px 5px;
      &:hover {
        color: blue;
        cursor: pointer;
        text-decoration: underline;
      }
    }
  }
}

.homeIndex-colTitles {
  height: 35px;
  display: flex;
  width: 483px;
  padding-right: 15px;
  flex-direction: row;
  justify-content: space-between;
  background-color: #E7F3FF;
  align-items: center;
  h3 {
    color: #336699;
    padding-left: 18px;
    background: url("../../static/lzbg5.gif") no-repeat 5px;
    background-size: 8px 8px;
  }
  span {
    color: #336699;
    &:hover {
      cursor: pointer;
      text-decoration: underline;
    }
  }
}

.homeIndex-colTitle {
  height: 35px;
  display: flex;
  width: 319px;
  flex-direction: row;
  justify-content: space-between;
  padding-right: 15px;
  background-color: #E7F3FF;
  align-items: center;
  h3 {
    color: #336699;
    padding-left: 18px;
    background: url("../../static/lzbg5.gif") no-repeat 5px;
    background-size: 8px 8px;
  }
  span {
    color: #336699;
    &:hover {
      cursor: pointer;
      text-decoration: underline;
    }
  }
}
</style>



